package com.smz.service.impl;

import com.smz.dao.RoleFunDAO;
import com.smz.entity.RoleFun;
import com.smz.service.RoleFunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleFunServiceImpl implements RoleFunService {

    @Autowired
    private RoleFunDAO roleFunDAO;


    @Override
    public String addRoleFunction(RoleFun roleFun) {
        RoleFun roleFun1 = roleFunDAO.selectRoleFunction(roleFun);
        if (roleFun1 ==null){
            roleFunDAO.insertRoleFunction(roleFun);
            return "ok";
        }
        return "exists";

    }

    @Override
    public String removeRoleFunction(RoleFun roleFun) {
        RoleFun roleFun1 = roleFunDAO.selectRoleFunction(roleFun);
        if(roleFun1 != null) {
            roleFunDAO.deleteRoleFunction(roleFun);
            return "ok";
        }
        return "not exists";
    }

    @Override
    public RoleFun findRoleFunction(RoleFun roleFun) {
        return roleFunDAO.selectRoleFunction(roleFun);
    }
}
